package com.telnetnz.ticketdesk.bean;

import com.telnetnz.ticketdesk.dao.entity.TicketToUserEntity;
import com.telnetnz.ticketdesk.service.TicketService;
import com.telnetnz.ticketdesk.service.UserService;

public class TicketToUser extends TicketToUserEntity {

	private static final long serialVersionUID = 6881442857300259844L;

	public Ticket getTicket() {
		return TicketService.getTicket(getTicketId());
	}

	public User getUser() {
		return UserService.getUser(getUserId());
	}

	public static TicketToUser adapt(TicketToUserEntity entity) {
		if (entity == null)
			return null;
		TicketToUser bean = new TicketToUser();
		bean.setTicketId(entity.getTicketId());
		bean.setUserId(entity.getUserId());
		bean.setCreateTime(entity.getCreateTime());
		return bean;
	}

	public TicketToUserEntity toEntity() {
		return this;
	}
}